<template>
	<view class="">
		<view class="u-padding-30">
			<upload_img ref="card_1" type="image" @uploaded="uploaded" :afterLoadUrl="image" defaultLength="3"
				width="200" height="200" cutType="">
			</upload_img>

			<view class="u-margin-bottom-20">
				<u-rate v-model="score"></u-rate>
			</view>

			<u-input type="textarea" v-model="liuyan" placeholder="快来评价吧~" border></u-input>
		</view>
		<u-toast ref="uToast" />

		<view class="bottomFixs" @click="ok">提交评价</view>

	</view>
</template>

<script>
	import upload_img from '../../components/upload_img.vue';

	export default {
		components: {
			upload_img
		},
		data() {
			return {
				liuyan: "",
				score: 5
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id = options.id
			}
		},
		methods: {
			ok() {
				if (!this.$refs.card_1.afterUploadImgList.length) {
					this.$u.toast("请上传图片")
					return
				}

				if (this.liuyan.length < 5) {
					this.$u.toast("不能少于五个字")
					return
				}

				this.$u.post('/api/indent/evaluate', {
					order_id: this.id,
					comment: this.liuyan,
					images: this.$refs.card_1.afterUploadImgList,
					score:this.score
				}).then(res => {
					this.$refs.uToast.show({
						title: '提交成功',
						type: 'success',
						back: true
					})
				}).catch(err => {

				})
			}
		}

	}
</script>

<style>
	.bottomFixs {
		background: #3464D6;
		text-align: center;
		width: 100%;
		padding: 30rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		color: #FFFFFF;
	}
</style>
